class ExtensionProcessorTest extends MediaWikiTestCase {
- private $dir;
+ private $dir, $dirname;
public function setUp() {
parent::setUp();
$this->dir = __DIR__ . '/FooBar/extension.json';
+ $this->dirname = dirname( $this->dir );
}
/**
self::$default,
$merge,
],
- // No current hooks, adding one for "FooBaz"
+ // No current hooks, adding one for "FooBaz" in string format
[
[],
[ 'Hooks' => [ 'FooBaz' => 'FooBazCallback' ] ] + self::$default,
[ 'Hooks' => [ 'FooBaz' => 'FooBazCallback' ] ] + self::$default,
[ 'FooBaz' => [ 'PriorCallback', 'FooBazCallback' ] ] + $merge,
],
+ // No current hooks, adding one for "FooBaz" in verbose array format
+ [
+ [],
+ [ 'Hooks' => [ 'FooBaz' => [ 'FooBazCallback' ] ] ] + self::$default,
+ [ 'FooBaz' => [ 'FooBazCallback' ] ] + $merge,
+ ],
// Hook for "BarBaz", adding one for "FooBaz"
[
[ 'BarBaz' => [ 'BarBazCallback' ] ],
}
/**
- * @covers ExtensionProcessor::extractConfig
+ * @covers ExtensionProcessor::extractConfig1
*/
- public function testExtractConfig() {
+ public function testExtractConfig1() {
$processor = new ExtensionProcessor;
$info = [
'config' => [
$this->assertEquals( 'somevalue', $extracted['globals']['egBar'] );
}
+ /**
+ * @covers ExtensionProcessor::extractConfig2
+ */
+ public function testExtractConfig2() {
+ $processor = new ExtensionProcessor;
+ $info = [
+ 'config' => [
+ 'Bar' => [ 'value' => 'somevalue' ],
+ 'Foo' => [ 'value' => 10 ],
+ 'Path' => [ 'value' => 'foo.txt', 'path' => true ],
+ ],
+ ] + self::$default;
+ $info2 = [
+ 'config' => [
+ 'Bar' => [ 'value' => 'somevalue' ],
+ ],
+ 'config_prefix' => 'eg',
+ 'name' => 'FooBar2',
+ ];
+ $processor->extractInfo( $this->dir, $info, 2 );
+ $processor->extractInfo( $this->dir, $info2, 2 );
+ $extracted = $processor->getExtractedInfo();
+ $this->assertEquals( 'somevalue', $extracted['globals']['wgBar'] );
+ $this->assertEquals( 10, $extracted['globals']['wgFoo'] );
+ $this->assertEquals( "{$this->dirname}/foo.txt", $extracted['globals']['wgPath'] );
+ // Custom prefix:
+ $this->assertEquals( 'somevalue', $extracted['globals']['egBar'] );
+ }
+
public static function provideExtractExtensionMessagesFiles() {
$dir = __DIR__ . '/FooBar/';
return [
]
];
}
+
+ public function testGlobalSettingsDocumentedInSchema() {
+ global $IP;
+ $globalSettings = TestingAccessWrapper::newFromClass(
+ ExtensionProcessor::class )->globalSettings;
+
+ $schema = FormatJson::decode(
+ file_get_contents( "$IP/docs/extension.schema.json" ),
+ true
+ );
+ $missing = [];
+ foreach ( $globalSettings as $global ) {
+ if ( !isset( $schema['properties'][$global] ) ) {
+ $missing[] = $global;
+ }
+ }
+
+ $this->assertEquals( [], $missing,
+ "The following global settings are not documented in docs/extension.schema.json" );
+ }
}
/**